package com.itheima.list;

import java.util.Iterator;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

public class Demo2 {
    public static void main(String[] args) {
        List<String> list = new CopyOnWriteArrayList<>();

        list.add("刘备");
        list.add("关羽");
        list.add("张飞");

        Iterator<String> it = list.iterator();

        while (it.hasNext()){
            if(it.next().equals("张飞")){
                list.add("张云");
            }
        }

        System.out.println(list);
    }
}
